import { encryptPassword } from '@/utils/utils'

export default {
    type: 'form',
    initApi: "/upms/crypto/key",
    api: {
      url:'/upms/admin/user/password/reset',
      method: 'post',
      requestAdaptor: function (api, context){
        let encodedPassword = encryptPassword(context.key, context.password);
        return {
          ...api,
          data: {
            id: context.id,
            password: encodedPassword
          }
        };
      }
    },
    messages:{
      validateFailed:''
    },
    body:[
      {
        type: 'hidden',
        name: 'id',
      },
      {
        type: 'static',
        name: 'username',
        label: '用户名'
      },
      {
        type: 'input-password',
        name: 'password',
        value: '',
        label: '新密码',
        required: true,
        validationErrors: {
          isRequired: '请输入新密码'
        }
      },
    ]
}